<?php

namespace App\Http\Requests\User;

use App\Http\Requests\BaseRequest;
use App\Http\Requests\SceneValidator;

class UserRequest extends BaseRequest
{
    use SceneValidator;
    /**
     * 这个地方记得为 true, 默认为 false 会返回 403 未授权提示
     * @return bool
     */
    public function authorize(): bool
    {
        return true;
    }

    /**
     * 验证规则
     * sometimes 存在时则验证
     * @return string[]
     */
    public function rules(): array
    {
        $rule = [
            'user_name'             => 'required',
            'password'              => 'required',
        ];
        return $rule;
    }

    /**
     * Notes:验证不通过提示
     * User: 'jiajia'
     * Date: 2025/10/17
     * Time: 10:18
     * @return string[]
     */
    public function messages(): array
    {
        return [
            'name.required'             => '用户名必填',
            'user_name.required'        => '账号必填',
            'password.required'         => '请输入密码',
            'password.min'              => '密码不得小于6位',
            'password.max'              => '密码不得大于30位',

        ];
    }

    /**
     * Notes:
     * User: 'jiajia'
     * Date: 2025/10/17
     * Time: 10:18
     * @return \string[][]
     */
    public function scene(): array
    {
        return [
            'login'               => ['user_name','password'],
            'add'                 => ['name'],
            'getRow'              => [],
            'update'              => ['user_id'],
            'delete'              => ['user_id'],
            'list'                => [],
            'getInfo'             => [],
            'getRouters'          => [],
        ];
    }
}
